<template>
	<view class="content">
		
		<view class="group">
			<view class="section">
				<view class="section_top">
					<view class="section_txt">您已经成功发起退款申请，请耐心等待商家处理！</view>
					<view class="section_dsc">如果商家拒绝，您可以重新修改申请后再次发起，商家会重新处理！</view>
					<view class="section_btn">
						<view class="botBtn" @click="changeApply(orderdatas)">修改申请</view>
						<view class="botBtn angin" @click="repealApply(orderdatas)">撤销申请</view>
					</view>
				</view>
				
			</view>
			<view class="section">
				<view class="order_title">退款信息</view>
				<view class="group_section">
					<view class="goods" v-for="(item,index) in orderdatas.cartInfo" :key="index">
						<image class="goodsImg" :src="item.productInfo.image" mode="aspectFill"></image>
						<view class="goods_info">
							<view class="goods_name ellipsis_2">{{item.productInfo.storeName}}</view>
							<view class="goods_attr">{{item.attrInfo.sku}}</view>
							<view class="goods_price">
								<view class="price">
									<view class="pricesign iconfont">&#xe604;</view>
									<view class="money">{{item.attrInfo.price}}
										<text >+{{item.attrInfo.integral}}通宝</text>
									</view>
								</view>
								<view class="goods_num">x{{item.cartNum}}</view>
							</view>
						</view>
					</view>
				</view>
			
				<view class="order_info_list">
					<view class="order_list_left">退款原因</view>
					<view class="order_info_detail">{{orderdatas.refundReasonWap}}</view>
				</view>
				<view class="order_info_list">
					<view class="order_list_left">申请时间</view>
					<view class="order_info_detail">{{orderdatas.refundReasonTime}}</view>
				</view>
				<view class="order_info_list">
					<view class="order_list_left">退款说明</view>
					<view class="order_info_detail">{{orderdatas.refundReasonWapExplain}}</view>
				</view>
				<view class="order_info_list">
					<view class="order_list_left">退款金额</view>
					<view class="order_info_detail" style="color: #E42221;">
						<text class="iconfont sign">&#xe604;</text>{{orderdatas.totalPrice}}
						<text>+{{orderdatas.totalIntegral}}通宝</text>
					</view>
				</view>
				
				
				
			</view>
			
		</view>
	
	
	</view>
</template>

<script>
	export default {
		data() {
			return {
				key:'' ,// 订单唯一标识
				orderdatas:{},
				
			}
		},
		onLoad(options) {
			console.log(options)
			if (Object.keys(options).length != 0) {
				this.key = options.key;
				this.getOrderDetail()
			}
			let that = this;
			uni.$on('myOrderDetail',function(data){
			    console.log('监听到事件来自 update ，携带参数 msg 为：' + data.msg);
				that.getOrderDetail(); //调用加载
			})
		},
		
		methods: {
			
			// 获取订单详情
			getOrderDetail: function () {
				let that = this;
				that.api.shoppingOrderDetail(that.key).then(res => {
					console.log(res)
					that.orderdatas = res.data;
				})
			},
			// 撤销申请
			repealApply: function (orderdatas) {
				let that = this;
				that.api.backoutApply({
					uni:orderdatas.unique
				}).then(res => {
					console.log(res)
					that.tui.toast(res.data);
					setTimeout(function () {
						uni.$emit('myOrder',{msg:'页面更新'})
						uni.$emit("myRrfund",{msg:'页面更新'})
						uni.navigateBack({
							delta: 1
						});
					},500)
					
				})
				
				
				
			},
			// 修改申请
			changeApply: function (orderdatas) {
				uni.navigateTo({
					url: '../refundOrder/refundOrder?key=' + orderdatas.unique,
				});
			}
			
 			
			
			
		}
	}
</script>

<style lang="less">
	page {
		width: 100%;
		box-sizing: border-box;
		letter-spacing: 3rpx;
		background: #F5F5F5;
		font-family: 'PingFang SC';
		font-size: 28rpx;
		color: #212121;
	}
	.content {
		width: 100%;
		box-sizing: border-box;
	}
	
	.group {
		width: 100%;
		box-sizing: border-box;
		padding: 10rpx 20rpx;
		margin-bottom: 130rpx;
		
		.section {
			width: 100%;
			box-sizing: border-box;
			background: #FFFFFF;
			border-radius: 12rpx;
			margin-bottom: 20rpx;
			.group_section {
				width: 100%;
				box-sizing: border-box;
				padding: 10rpx 20rpx;
				background: #FFFFFF;
				border-radius: 12rpx;
				.goods {
					width: 100%;
					box-sizing: border-box;
					display: flex;
					justify-content: space-between;
					padding: 20rpx 0;
					.goodsImg {
						width: 160rpx;
						height: 160rpx;
						border-radius: 16rpx;
					}
					.goods_info {
						width: calc(100% - 160rpx);
						box-sizing: border-box;
						padding-left: 20rpx;
						display: flex;
						flex-flow: column;
						justify-content: space-between;
						font-size: 28rpx;
						color: #140005;
						.goods_price {
							width: 100%;
							box-sizing: border-box;
							display: flex;
							justify-content: space-between;
							align-items: center;
							font-size: 22rpx;
							color: #212121;
							.price {
								display: flex;
								justify-content: flex-start;
								align-items: center;
								font-size: 28rpx;
								color: #E42221;
								.pricesign {
									color: #FFDA71;
									font-size: 26rpx;
									// padding-top: 5rpx;
								}
							}
						}
						.goods_attr {
							width: 100%;
							box-sizing: border-box;
							font-size: 24rpx;
							color: #999999;
						}
						
					}
					
				}
			}
			
			.order_total {
				width: 100%;
				box-sizing: border-box;
				line-height: 100rpx;
				display: flex;
				justify-content: space-between;
				align-items: center;
				padding: 0 22rpx;
				border-bottom: 2rpx solid #F5F5F5;
				font-size: 28rpx;
				color: #333333;
				font-weight: 500;
			}
		
			.order_title {
				width: 100%;
				box-sizing: border-box;
				padding: 0 20rpx;
				line-height: 102rpx;
				font-size: 30rpx;
				font-weight: 500;
			}
			.order_info_list {
				width: 100%;
				box-sizing: border-box;
				display: flex;
				justify-content: space-between;
				align-items: center;
				padding: 20rpx;
				line-height: 60rpx;
				font-size: 28rpx;
				color: #212121;
				border-top: 2rpx solid #F5F5F5;
				.order_list_left {
					width: 162rpx;
					box-sizing: border-box;
					color: #666666;
				}
				.order_info_detail {
					width: calc(100% - 162rpx);
					box-sizing: border-box;
					text-align: right;
					.sign {
						color: #FFDA71;
						font-size: 26rpx;
					}
				}
				
			}
			.section_top {
				width: 100%;
				box-sizing: border-box;
				padding: 30rpx 22rpx;
				.section_txt {
					width: 100%;
					box-sizing: border-box;
					font-size: 28rpx;
					color: #333333;
					font-weight: 300;
					line-height: 40rpx;
				}
				.section_dsc {
					width: 100%;
					box-sizing: border-box;
					font-size: 22rpx;
					color: #666666;
					line-height: 40rpx;
				}
				.section_btn {
					width: 100%;
					box-sizing: border-box;
					display: flex;
					justify-content: flex-end;
					align-items: center;
					padding-top: 20rpx;
					.botBtn {
						width: 146rpx;
						box-sizing: border-box;
						text-align: center;
						line-height: 50rpx;
						border: 1rpx solid #999999;
						color: #999999;
						font-size: 24rpx;
						color: #999999;
						border-radius: 100rpx;
						margin-left: 28rpx;
						&.angin {
							border-radius: 1rpx solid #E42221;
							color: #E42221;
						}
					}
					
					
					
					
				}
				
			}
			
		}
		
	}
	
	
</style>
